/*
 * Copyright 2008 Hector Francisco Hernandez
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

var gorillaArray = new Array();

function gorillaInit(canvas, leftGorillaPosition, rightGorillaPosition)
{
  gorilla = new Object();
  gorilla.x = leftGorillaPosition[0];
  gorilla.y = leftGorillaPosition[1];
  gorilla.width = 20;
  gorilla.height = 20;
  gorillaArray.push(gorilla);

  gorilla = new Object();
  gorilla.x = rightGorillaPosition[0];
  gorilla.y = rightGorillaPosition[1];
  gorilla.width = 20;
  gorilla.height = 20;
  gorillaArray.push(gorilla);

  canvas.innerHTML += "<img name=\"gorillaLeft\" " +
      "style=\"position:absolute; left:" + gorillaArray[0].x + "px; " +
      "top:" + gorillaArray[0].y + "px\" src=\"gorilla.gif\">";

  canvas.innerHTML += "<img name=\"gorillaRight\" " +
      "style=\"position:absolute; left:" + gorillaArray[1].x + "px; " +
      "top:" + gorillaArray[1].y + "px\" src=\"gorilla.gif\">";

}

function gorillaGetLeftShootPosition()
{
  return [gorillaArray[0].x, gorillaArray[0].y];
}

function gorillaGetRightShootPosition()
{
  return [gorillaArray[1].x + 20, gorillaArray[1].y];
}

function gorillaLeftIsIn(x, y)
{
  if (x > gorillaArray[0].x && x < gorillaArray[0].x + gorillaArray[0].width) {
    if (y > gorillaArray[0].y && y < gorillaArray[0].y +
        gorillaArray[0].height) {
      return true;
    }
  }

  return false;
}

function gorillaRightIsIn(x, y)
{
  if (x > gorillaArray[1].x && x < gorillaArray[1].x + gorillaArray[1].width) {
    if (y > gorillaArray[1].y && y < gorillaArray[1].y +
        gorillaArray[1].height) {
      return true;
    }
  }

  return false;
}

function gorillaLeftExplode()
{
  document.gorillaLeft.src = "explotion.gif";
  document.gorillaLeft.style.left = gorillaArray[0].x - 25;
  document.gorillaLeft.style.top = gorillaArray[0].y - 40;
}

function gorillaRightExplode()
{
  document.gorillaRight.src = "explotion.gif";
  document.gorillaRight.style.left = gorillaArray[1].x - 25;
  document.gorillaRight.style.top = gorillaArray[1].y - 40;
}

